<?php
/*
if ((($_FILES["fFile"]["type"] == "image/gif") || ($_FILES["fFile"]["type"] == "image/jpeg") || ($_FILES["fFile"]["type"] == "image/pjpeg") || ($_FILES["fFile"]["type"] == "image/jpg")) && ($_FILES["fFile"]["size"] < 20000000)) {
    if ($_FILES["fFile"]["error"] > 0) {
        echo "Return Code: " . $_FILES["fFile"]["error"] . "<br />";
    } else {
        echo "Upload: " . $_FILES["fFile"]["name"] . "<br />";
        echo "Type: " . $_FILES["fFile"]["type"] . "<br />";
        echo "Size: " . ($_FILES["fFile"]["size"] / 1024) . " Kb<br />";
        echo "Temp file: " . $_FILES["fFile"]["tmp_name"] . "<br />";
        if (file_exists("/Library/WebServer/Documents/FileUploadTest/upload/" . $_FILES["fFile"]["name"])) {
            echo $_FILES["fFile"]["name"] . " already exists. ";
        } else {
            move_uploaded_file($_FILES["fFile"]["tmp_name"],"/Library/WebServer/Documents/FileUploadTest/upload/" . $_FILES["fFile"]["name"]);
            echo "Stored in: " . "/Library/WebServer/Documents/FileUploadTest/upload/" . $_FILES["fFile"]["name"];
        }
    }
} else {
    echo $_FILES["fFile"]["type"];
    echo "Invalid file";
}
*/

for ($i = 0; $i < 5; $i++) {

    if ($_FILES["fFile".$i]["error"] > 0) {
        echo "Return Code: " . $_FILES["fFile".$i]["error"] . "<br />";
    } else {
        if (file_exists("/Library/WebServer/Documents/FileUploadTest/upload/" . $_FILES["fFile".$i]["name"])) {
            echo $_FILES["fFile".$i]["name"] . " already exists. ";
        } else {
            move_uploaded_file($_FILES["fFile".$i]["tmp_name"],"/Library/WebServer/Documents/FileUploadTest/upload/" . $_FILES["fFile".$i]["name"]);
            echo "Stored in: " . "/Library/WebServer/Documents/FileUploadTest/upload/" . $_FILES["fFile".$i]["name"];
        }
    }

}


$sText='';
foreach ($_FILES as $k => $v) {
    $sText.=$k.'\n';
    foreach ($v as $kk => $vv) {
        if ($kk != 'tmp_name') {
            $sText.=' '.$kk.'='.$vv.'\n';
        }
    }
}
?>
<html>
    <head>
        <script>isLoaded = true;</script>
    </head>
    <body>
        <textarea>{'status':'Good','textdata':'<?php echo $_POST["name"]; ?>'}</textarea>
    </body>
</html>